<?php

namespace app\library;

class LayuiJson {
    /**
     * @param    [integer]                $code  [状态码]
     * @param    int                      $count [总行数]
     * @param    string                   $msg   [提示信息]
     * @param    array                    $data  [数据]
     * @return   [sting]                         [返回json数据]
     */
    public static function tableJson($data = array(), $count = -1 ,$code = 0, $msg = '') {
        if(!is_numeric($code)) {    //判断是否数字
            return '';
        }
        if ($count == -1){
            $count = count($data);
        }
        $result = array(
            'code' => $code,
            'count'=> $count,
            'data' => $data,
            'msg' => $msg,
        );
        echo json_encode($result);
        exit;
    }
}